import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'providers/theme_provider.dart';
import 'providers/font_size_provider.dart';
import 'navigation/app_router.dart';

class StudyTreasureApp extends StatelessWidget {
  const StudyTreasureApp({super.key});

  @override
  Widget build(BuildContext context) {
    final appRouter = AppRouter();
    
    return Consumer2<ThemeProvider, FontSizeProvider>(
      builder: (context, themeProvider, fontSizeProvider, child) {
        return MaterialApp.router(
          title: '学习宝藏',
          debugShowCheckedModeBanner: false,
          theme: themeProvider.lightTheme,
          darkTheme: themeProvider.darkTheme,
          themeMode: themeProvider.themeMode,
          routerConfig: appRouter.router,
          builder: (context, child) {
            final mediaQueryData = MediaQuery.of(context);
            final scale = fontSizeProvider.fontScale;
            
            return MediaQuery(
              data: mediaQueryData.copyWith(textScaleFactor: scale),
              child: child!,
            );
          },
        );
      },
    );
  }
}